<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <?php include "../public/substt.php";?>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>项目基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" id="number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目类型</label>
                        <div class="layui-input-block">
                            <div id="engintype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方/建设单位</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="jian_unit" class="layui-input jian_unit" onclick="openPage('../public/choose_dealcom.php?dom=jian_unit','80%','80%')">
                            <div class="choose_div" id="jian_unit" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=jian_unit','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目所在地</label>
                        <div class="layui-input-block" style="z-index: 1;">
                            <input type="text" name="areas" id="areas" placeholder="请选择" readonly clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="addr" id="addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">资质要求</label>
                        <div class="layui-input-block">
                            <input type="text" name="ziyao" id="ziyao" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目所属单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=chanid&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="chanid"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=chanid&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="chanid_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目属性</label>
                        <div class="layui-input-block">
                            <select id="business" name="business" lay-filter="business" >
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                            <p class="error" id="business_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item business2 layui-hide">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>联营方/委托方</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="lian_unit" class="layui-input lian_unit" onclick="openPage('../public/choose_dealcom.php?dom=lian_unit','80%','80%')">
                            <div class="choose_div" id="lian_unit" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=lian_unit','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">项目概况</label>
                        <div class="layui-input-block">
                            <textarea id="kuang" name="kuang" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>招标信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">预计工程造价(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="yuzaofee" id="yuzaofee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标代理机构</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhao_unit" id="zhao_unit" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标保证金金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="baofee" id="baofee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>!</text>投标截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt_tou" id="enddt_tou" placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>!</text>开标时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaidt" id="kaidt" placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">招标说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaoshuo" id="zhaoshuo" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>投标信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>参投单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=touunit&type=dept&dept=chan&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="touunit"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=touunit&type=dept&dept=chan&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="touunit_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">编标员</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=bianer&type=user&single=2', '770px', '490px');"></div>
                                <div class="tanxiannei" id="bianer"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=bianer&type=user&single=2', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">投标说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="toushuo" id="toushuo" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>开标信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">开标结果</label>
                        <div class="layui-input-block">
                            <select id="kaiguo" name="kaiguo" lay-filter="kaiguo" >
                                <option value="">请选择</option>
                                <option value="中标">中标</option>
                                <option value="未中标">未中标</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide wininfo">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">中标单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=winunit&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="winunit"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=winunit&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="winunit_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide wininfo">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">中标金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="winfee" id="winfee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">中标日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="windt" id="windt" placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">开标说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaishuo" id="kaishuo" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>




            <?php include '../public/flowqita.php'?>
            <?php include '../public/upinfo.php'?>

        </div>
    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    chu_flow_edit_yushen();

    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_edit_engin,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                chu_flow_qian(data);


                $("#name").val(data.name);
                $("#number").val(data.number);
                $("#addr").val(data.addr);
                $("#areas").val(data.areas);
                $("#ziyao").val(data.ziyao);
                $("#business").val(data.business);
                $("#kuang").val(data.kuang);
                $("#explain").val(data.explain);

                $("#yuzaofee").val(data.yuzaofee);
                $("#zhao_unit").val(data.zhao_unit);
                $("#baofee").val(data.baofee);
                $("#enddt_tou").val(data.enddt_tou);
                $("#kaidt").val(data.kaidt);
                $("#zhaoshuo").val(data.zhaoshuo);
                $("#toushuo").val(data.toushuo);
                $("#kaiguo").val(data.kaiguo);
                $("#winfee").val(data.winfee);
                $("#windt").val(data.windt);
                $("#kaishuo").val(data.kaishuo);

                if(data.jian_unit){
                    set_choose_btn('jian_unit',data.jian_unit,data.jian_unit);
                }
                if(data.lian_unit){
                    set_choose_btn('lian_unit',data.lian_unit,data.lian_unit);
                }
                if(data.chanid_info.length > 0){
                    tan_tags_init('#chanid', data.chanid_info);
                }
                if(data.touunit_info.length > 0){
                    tan_tags_init('#touunit', data.touunit_info);
                }
                if(data.winunit_info.length > 0){
                    tan_tags_init('#winunit', data.winunit_info);
                }
                if(data.bianer_info.length > 0){
                    tan_tags_init('#bianer', data.bianer_info);
                }

                load_areas('areas', res.data.areas, 3);
                xmselect_dan('engintype', res.data.engintype, data.engintype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#engintype").find('xm-select').removeClass('error');
                    }else{
                        $("#engintype").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('zhaotype', res.data.zhaotype, data.zhaotype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#zhaotype").find('xm-select').removeClass('error');
                    }else{
                        $("#zhaotype").find('xm-select').addClass('error');
                    }
                });

                if(data.business == 2){
                    $(".business2").removeClass('layui-hide');
                }else{
                    $(".business2").addClass('layui-hide');
                }

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(data.state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else{
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }
                }
                $("#state").html(state_str);

                if(data.kaiguo == '中标'){
                    $(".wininfo").removeClass('layui-hide');
                }else{
                    $(".wininfo").addClass('layui-hide');
                }

                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });


        form.on('select(business)', function(data){
            if(data.value == 2){
                $(".business2").removeClass('layui-hide');
            }else{
                $(".business2").addClass('layui-hide');
            }

            if(data.value == ''){
                $('#state_error').show().text('请选择');
                $('#state_error').parent().find('input').addClass('select_error');
            }else{
                $('#state_error').hide();
                $('#state_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(kaiguo)', function(data){
            if(data.value == '中标'){
                $(".wininfo").removeClass('layui-hide');
            }else{
                $(".wininfo").addClass('layui-hide');
            }
        });


        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.isshen = $(this).attr('isshen') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');

            data.field.chanid = tan_tags_getvalue("#chanid", 'dept');
            data.field.lian_unit = get_choose_val('lian_unit');
            data.field.jian_unit = get_choose_val('jian_unit');
            data.field.touunit = tan_tags_getvalue("#touunit", 'dept');
            data.field.bianer = tan_tags_getvalue("#bianer", 'user');
            data.field.winunit = tan_tags_getvalue("#winunit", 'dept');

            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                if(!data.field.engintype){
                    $("#engintype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#engintype").find('xm-select').removeClass('error');
                }

                if(!data.field.zhaotype){
                    $("#zhaotype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#zhaotype").find('xm-select').removeClass('error');
                }

                if(!data.field.chanid){
                    $("#chanid").parents('.tanxian').addClass('tanerror');
                    $('#chanid_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#chanid").parents('.tanxian').removeClass('tanerror');
                    $('#chanid_tanerror').text('');
                }

                if(data.field.business == ''){
                    $('#business_error').show().text('请选择');
                    $('#business_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#business_error').hide();
                    $('#business_error').parent().find('input').removeClass('select_error');
                }

                if(data.field.business == 2){
                    formValid('lian_unit');
                    if(data.field.lian_unit == undefined || !data.field.lian_unit){
                        validRes = false;
                    }
                }


                if(!data.field.touunit){
                    $("#touunit").parents('.tanxian').addClass('tanerror');
                    $('#touunit_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#touunit").parents('.tanxian').removeClass('tanerror');
                    $('#touunit_tanerror').text('');
                }

                if(!validRes){return false;}
            }


            data = parseMoney(data);
            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');

            public_flow_submit(data.field, ask_flowdata_add_engin, ask_flowdata_edit_engin, $(this).attr('but'));
            return false;
        });

    });


</script>
</body>
</html>
